﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace WaveSim.Core.Equations.Galerkin
{
    public class Composite : BaseDielectric
    {
        public Composite()
        {
            Components = new List<BaseDielectric>();
        }

        public Composite(IEnumerable<BaseDielectric> dielectricList)
        {
            Components = dielectricList.ToList();
        }

        public List<BaseDielectric> Components { get; private set; }

        /// <summary>
        /// Returns a value of epsilon
        /// </summary>
        /// <param name="coordinate">x and z values</param>
        /// <returns></returns>
        public override Complex Eps(params double[] coordinate)
        {
            if (Components == null || Components.Count == 0)
                return DefaultValue;

            foreach (var dielectric in Components)
            {
                var eps = dielectric.Eps(coordinate);
                if (eps != DefaultValue)
                    return eps;
            }
            return DefaultValue;
        }

        /// <summary>
        /// Returns a value of mu
        /// </summary>
        /// <param name="coordinate">x and z values</param>
        /// <returns></returns>
        public override Complex Mu(params double[] coordinate/*x,z*/)
        {
            return DefaultValue;
        }
    }
}
